import 'package:fluro/fluro.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' hide Router;
import 'package:megatron/const.dart';

import 'routes.dart';

///启动
void main() {
  WidgetsFlutterBinding.ensureInitialized();

  ///初始化并配置路由
  Routes.configureRoutes(FluroRouter());
//  _setAmapKey();

  runApp(MaterialApp(
      theme: ThemeData(
          appBarTheme: AppBarTheme(
        elevation: 0,
        color: Const.blue,
        iconTheme: IconThemeData(color: Colors.white),
        actionsIconTheme: IconThemeData(color: Colors.white),
      )),
      onGenerateRoute: Routes.router.generator));
}

//_setAmapKey() async {
//  await AmapCore.init('8694c5e4a62d20736a2919631b658bad');
//}

/// 根界面 决定跳转的页面
class PageRoot extends StatefulWidget {
  PageRoot({Key key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => PageRootState();
}

class PageRootState extends State<PageRoot> {
  String result;

  @override
  void initState() {
    super.initState();

    Future.delayed(Duration(seconds: 0), () {
      intentMain();
    });
  }

  intentMain() async {
    String route = '${Routes.login}';
    Routes.router.navigateTo(context, route,
        replace: true, transition: TransitionType.fadeIn);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      color: Colors.transparent,
    );
  }
}
